package com.market.cash.ui.adapter

import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/22 10:43
 * @Annotation：流程 - Ocr 适配器
 */
class CashRootStepOcrTypeAdapter(recyclerView: RecyclerView?) : CashRootRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.cash_step_ocr_type_item) {

    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout)
    }

    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        val itemLayout = helper.getView<LinearLayout>(R.id.itemLayout)
        val imgOcrType = helper.getImageView(R.id.imgOcrType)
        imgOcrType.setImageResource(model.optInt("imgResource"))
        val textOcrType = helper.getTextView(R.id.textOcrType)
        textOcrType.text = model.optString("ocrTitle")

        val isSelect = model.optBoolean("isSelect",false)
        when (isSelect){
            true -> {
                itemLayout.setBackgroundResource(R.drawable.cash_radius_frame_435cfa_alph10_10)
            }
            else -> {
                itemLayout.setBackgroundResource(R.drawable.cash_radius_fill_f8f8f8_10)
            }
        }
    }
}